﻿#region Using Directives

using System;
using System.Collections;
using System.Drawing;
using GoldParser;
using Licenta1;
using Licenta1.Expressions;
using Licenta1.Statements;
using System.Collections.Generic;
using TinyRaytracer;

#endregion

namespace Licenta1
{
    [Serializable]
    public class Context
    {
        public Parser parser;
        public Hashtable variables = new Hashtable();
        public Color activeColor;
        public Pen activePen;
        public ArrayList userCollections;
        public ArrayList userFunctions;
        public MainParsing mp;

        public Context(Parser p, MainParsing parsing)
        {
            mp = parsing;
            parser = p;
            userCollections = new ArrayList();
            userFunctions = new ArrayList();
            activeColor = Color.Black;
            activePen = new Pen(activeColor, 1);
        }

        public Node GetObject()
        {
            switch ((Rules)parser.ReductionRule.Index)
            {
                #region Statements Rules

                case Rules.RULE_START_2D:
                case Rules.RULE_START_3D:
                    return new DimensionStatement(this, Token(0), Statement(1));

                case Rules.RULE_STATEMENTS:
                case Rules.RULE_STATEMENTS2:
                    return new StatementList(this, Statement(0), Statement(1));

                case Rules.RULE_STATEMENT_LPARAN_RPARAN:
                    {
                        if (Token(0) == "display")
                            return new DisplayStatement(this, Expression(2));
                        else if (Token(0) == "draw")
                            return new DrawStatement(this, Expression(2));
                        return null;
                    }


                case Rules.RULE_STATEMENT_SAVE_STRINGLITERAL:
                    {
                        //Console.WriteLine("Save string statement."); 
                        return new SaveStatement(this, Token(0), Expression(1));
                    }

                case Rules.RULE_STATEMENT_LOAD_STRINGLITERAL:
                    {
                        //Console.WriteLine("Load string statement."); 
                        return new LoadStatement(this, Token(0));
                    }

                case Rules.RULE_STATEMENT_ID_EQ:// to check for now
                    {
                        ////Console.WriteLine("Assignement called with args: " + Expression(0).ToString() + " and " + Expression(2).ToString());
                        
                        return new AssignmentStatement(this, Expression(0), Expression(2));
                    }

                case Rules.RULE_STATEMENT_IF_THEN_ENDIF:
                    {
                        ////Console.WriteLine("If then.");
                        return new IfThenStatement(this, Expression(1), Statement(3));
                    }

                case Rules.RULE_STATEMENT_IF_THEN_ELSE_ENDIF:
                    {
                        ////Console.WriteLine("IfThenElse.");
                        return new IfThenElseStatement(this, Expression(1), Statement(3), Statement(5));
                    }

                case Rules.RULE_STATEMENT_WHILE_DO_ENDWHILE:
                    {
                        ////Console.WriteLine("While.");
                        return new WhileStatement(this, Expression(1), Statement(3));
                    }

                case Rules.RULE_STATEMENT_COLOR:
                    return new ColorStatement(this, Token(1));

                case Rules.RULE_STATEMENT_COLLECTION_ID:
                    {
                        return new CollectionStatement(this, Expression(1));
                    }

                case Rules.RULE_STATEMENT_ID_DOT_ADD_LPARAN_RPARAN:
                    {
                        return new CollectionAddStatement(this, Expression(0), Expression(4));
                    }

                case Rules.RULE_STATEMENT_ID_DOT_REMOVE_LPARAN_RPARAN:
                    {
                        return new CollectionRemoveStatement(this, Expression(0), Expression(4));
                    }

                case Rules.RULE_STATEMENT_CLEAR_ID:
                    {
                        return new CollectionClearStatement(this, Expression(1));
                    }

                case Rules.RULE_STATEMENT_PEN_ID:
                case Rules.RULE_STATEMENT_PEN_NUMBERLITERAL:
                    return new PenStatement(this, Expression(1));

                case Rules.RULE_STATEMENT_FUNCTION_ID_LPARAN_RPARAN_EXIT_END:
                    return new FunctionStatement(this, Expression(1), Statement(5), Expression(3));

                case Rules.RULE_STATEMENT_APPENDLIGHT_LPARAN_RPARAN:
                    return new AppendLightStatement(this, Expression(2));

                case Rules.RULE_STATEMENT_SETCAMERA_LPARAN_RPARAN:
                    return new SetCameraStatement(this, Expression(2));

                //case Rules.RULE_STATEMENT_PROCEDURE_ID_LPARAN_RPARAN_END:
                  //  return new ProcedureStatement(this, Expression(1), Expression(3), Statement(5));

                #endregion
                
                #region Bool Expressions

                case Rules.RULE_BOOL_EXPRESSION_TRUE:
                        return new BooleanValue(this, true);
         
                case Rules.RULE_BOOL_EXPRESSION_FALSE:
                    return new BooleanValue(this, false);

                case Rules.RULE_BOOL_EXPRESSION:
                    return new BooleanExpression(this, Expression(0), Token(1), Expression(2));

                case Rules.RULE_BOOL_EXPRESSION_LPARAN_RPARAN:
                    return new BooleanExpression(this, Expression(1), Token(2), Expression(3));

                
                #endregion

                #region MathExpressions

                case Rules.RULE_MATH_EXPRESSION_ID:
                    {
                        ////Console.WriteLine("Apelat Math Id.");
                        return new ObjectMathExpressionID(this, Expression(0));
                    }

                case Rules.RULE_MATH_EXPRESSION_NUMBERLITERAL:
                    {
                        ////Console.WriteLine("Apelat Math Nr with " + Token(0));
                        return new NumberExpression(this, Token(0));
                    }

                case Rules.RULE_MATH_EXPRESSION:
                    {
                        ////Console.WriteLine("Apelat Math Math.");
                        return new MathBinaryExpression(this, Expression(0), GenToken(1), Expression(2));
                    }

                case Rules.RULE_MATH_EXPRESSION_LPARAN_RPARAN:
                    {
                        ////Console.WriteLine("Apelat (Math).");
                        return new ObjectMathExpression(this, Expression(1));
                    }

                case Rules.RULE_MATH_EXPRESSION_MINUS:
                    {
                        ////Console.WriteLine("Apelat Math -.");
                        return new MathNegativeExpression(this, Expression(1));
                    }

                #endregion

                #region Params

                case Rules.RULE_PARAMS_COMMA:
                    {
            //            Console.WriteLine("Build ParamList with:" + Expression(0) + " and " + Expression(2));
                        return new ParameterList(this, Expression(0), Expression(2));
                    }

                case Rules.RULE_PARAMS2:
                    {
            //            Console.WriteLine("Build ParamList with:" + Expression(0)); 
                        return new ParameterList(this, Expression(0), null);
                    }

                case Rules.RULE_PARAMS:
                    return new ParameterList(this, null, null);

                #endregion

                #region ObjectRules

                case Rules.RULE_OBJECT:
                    {
                        return new ObjectMathExpression(this, Expression(0));
                    }

                case Rules.RULE_OBJECT_STRINGLITERAL:
                    {
                        return new StringExpression(this, (string)Expression(0).Value);
                    }

                case Rules.RULE_OBJECT_LPARAN_RPARAN:
                    {
                        //Console.WriteLine("Apelat Object  ( ).");
                        return new ObjectExpression(this, Token(0), Expression(2));
                    }

                case Rules.RULE_OBJECT_LPARAN_RPARAN2:
                    {
                        //Console.WriteLine("Apelat Object ()2");
                        return new ObjectTrExpression(this, Token(0), Expression(1), Expression(3));
                    }


                case Rules.RULE_OBJECT_ID_LBRACKET_RBRACKET:
                    return new CollectionIndexExpressions(this, Expression(0), Expression(2));

                case Rules.RULE_OBJECT_ID_DOT_FIRST:
                    return new CollectionFirstExpressions(this, Expression(0));

                case Rules.RULE_OBJECT_ID_DOT_LAST:
                    return new CollectionLastExpressions(this, Expression(0));

                case Rules.RULE_OBJECT_ID_DOT_SIZE:
                    return new CollectionSizeExpressions(this, Expression(0));

                case Rules.RULE_OBJECT_ID_LPARAN_RPARAN:
                    return new FunctionExpression(this, Expression(0), Expression(2));

                #endregion

                default: return new GenericExpression(this, Token(0));

            }
        }


        public Expression GetTokenText()
        {
            switch ((Symbols)parser.TokenSymbol.Index)
            {
                case Symbols.SYMBOL_BEZIER:
                case Symbols.SYMBOL_BMP:
                case Symbols.SYMBOL_BOOL_EXPRESSION:
                case Symbols.SYMBOL_CIRCLE:
                case Symbols.SYMBOL_COMMA:
                case Symbols.SYMBOL_CUBE:
                case Symbols.SYMBOL_CSG:
                case Symbols.SYMBOL_SPHERE:
                case Symbols.SYMBOL_DISPLAY:
                case Symbols.SYMBOL_DIV:
                case Symbols.SYMBOL_DO:
                case Symbols.SYMBOL_DRAW:
                case Symbols.SYMBOL_ELLIPSE:
                case Symbols.SYMBOL_ELSE:
                case Symbols.SYMBOL_ENDIF:
                case Symbols.SYMBOL_ENDWHILE:
                case Symbols.SYMBOL_EOF:
                case Symbols.SYMBOL_EQ:
                case Symbols.SYMBOL_EQEQ:
                case Symbols.SYMBOL_ERROR:
                case Symbols.SYMBOL_EXCLAMEQ:
                case Symbols.SYMBOL_FALSE:
                case Symbols.SYMBOL_FORMAT:
                case Symbols.SYMBOL_GT:
                case Symbols.SYMBOL_GTEQ:
                case Symbols.SYMBOL_IF:
                case Symbols.SYMBOL_JPEG:
                case Symbols.SYMBOL_JPG:
                case Symbols.SYMBOL_LINE:
                case Symbols.SYMBOL_LOAD:
                case Symbols.SYMBOL_LPARAN:
                case Symbols.SYMBOL_LT:
                case Symbols.SYMBOL_LTEQ:
                case Symbols.SYMBOL_MINUS:
                case Symbols.SYMBOL_NUMBERLITERAL:
                case Symbols.SYMBOL_PERCENT:
                case Symbols.SYMBOL_PLUS:
                case Symbols.SYMBOL_PNG:
                case Symbols.SYMBOL_POINT:
                case Symbols.SYMBOL_POLYGON:
                case Symbols.SYMBOL_RECTANGLE:
                case Symbols.SYMBOL_REFLECTION:
                case Symbols.SYMBOL_RPARAN:
                case Symbols.SYMBOL_SAVE:
                case Symbols.SYMBOL_SCALING:
                case Symbols.SYMBOL_SQUARE:
                case Symbols.SYMBOL_THEN:
                case Symbols.SYMBOL_TIMES:
                case Symbols.SYMBOL_TRUE:
                case Symbols.SYMBOL_WHILE:
                case Symbols.SYMBOL_WHITESPACE:
                case Symbols.SYMBOL_2D:
                case Symbols.SYMBOL_3D:
                case Symbols.SYMBOL_CLEAR:
                case Symbols.SYMBOL_COLLECTION:
                case Symbols.SYMBOL_COLOR:
                case Symbols.SYMBOL_GREEN:
                case Symbols.SYMBOL_RED:
                case Symbols.SYMBOL_ORANGE:
                case Symbols.SYMBOL_YELLOW:
                case Symbols.SYMBOL_BLUE:
                case Symbols.SYMBOL_BLACK:
                case Symbols.SYMBOL_PURPLE:
                case Symbols.SYMBOL_WHITE:
                case Symbols.SYMBOL_LBRACKET:
                case Symbols.SYMBOL_RBRACKET:
                case Symbols.SYMBOL_ADD:
                case Symbols.SYMBOL_CALL:
                case Symbols.SYMBOL_EXIT:
                case Symbols.SYMBOL_FUNCTION:
                case Symbols.SYMBOL_PLANE:
                case Symbols.SYMBOL_SETCAMERA:
                case Symbols.SYMBOL_APPENDLIGHT:
                //case Symbols.SYMBOL_END:
                case Symbols.SYMBOL_REMOVE:
                    return new GenericExpression(this, parser.TokenText);
                case Symbols.SYMBOL_ID:
                    return new IdentifierExpression(this, parser.TokenText);
                case Symbols.SYMBOL_STRINGLITERAL:
                    return new StringExpression(this, parser.TokenText);
                default: return null;
            }
        }

        public bool AddVariable(string varName, object Value)
        {
            if (variables.ContainsKey(varName))
                return false;
            else
            {
                variables.Add(varName, Value);
                return true;
            }
        }

        private Expression Expression(int index)
        {
            object o = parser.GetReductionSyntaxNode(index);

            //Console.WriteLine("Obiect pentru expr cast " + o.ToString());

            return (Expression)o;
        }

        private Statement Statement(int index)
        {
            return (Statement)parser.GetReductionSyntaxNode(index);
        }

        private string Token(int index)
        {
            object o = parser.GetReductionSyntaxNode(index);
//            ////Console.WriteLine("Token: index = " + index + ": o = " + o.ToString() + "TokenString: " + parser.TokenText);
            return ((GenericExpression)o).Value.ToString();
        }

        private string StringToken(int index)
        {
            object o = parser.GetReductionSyntaxNode(index);
            //Console.WriteLine("Token: index = " + index + ": o = " + o.ToString() + "TokenString: " + parser.TokenText);
            return (string)o;
        }

        private GenericExpression GenToken(int index)
        {
            return (GenericExpression)parser.GetReductionSyntaxNode(index);
        }

        #region Constants

        enum Symbols : int
        {
            /// <c> (EOF) </c>
            SYMBOL_EOF = 0,
            /// <c> (Error) </c>
            SYMBOL_ERROR = 1,
            /// <c> (Whitespace) </c>
            SYMBOL_WHITESPACE = 2,
            /// <c> '-' </c>
            SYMBOL_MINUS = 3,
            /// <c> '!=' </c>
            SYMBOL_EXCLAMEQ = 4,
            /// <c> '%' </c>
            SYMBOL_PERCENT = 5,
            /// <c> '(' </c>
            SYMBOL_LPARAN = 6,
            /// <c> ')' </c>
            SYMBOL_RPARAN = 7,
            /// <c> '*' </c>
            SYMBOL_TIMES = 8,
            /// <c> ',' </c>
            SYMBOL_COMMA = 9,
            /// <c> '.' </c>
            SYMBOL_DOT = 10,
            /// <c> '/' </c>
            SYMBOL_DIV = 11,
            /// <c> '[' </c>
            SYMBOL_LBRACKET = 12,
            /// <c> ']' </c>
            SYMBOL_RBRACKET = 13,
            /// <c> '{' </c>
            SYMBOL_LBRACE = 14,
            /// <c> '}' </c>
            SYMBOL_RBRACE = 15,
            /// <c> '+' </c>
            SYMBOL_PLUS = 16,
            /// <c> '&lt;' </c>
            SYMBOL_LT = 17,
            /// <c> '&lt;=' </c>
            SYMBOL_LTEQ = 18,
            /// <c> '=' </c>
            SYMBOL_EQ = 19,
            /// <c> '==' </c>
            SYMBOL_EQEQ = 20,
            /// <c> '&gt;' </c>
            SYMBOL_GT = 21,
            /// <c> '&gt;=' </c>
            SYMBOL_GTEQ = 22,
            /// <c> '2D' </c>
            SYMBOL_2D = 23,
            /// <c> '3D' </c>
            SYMBOL_3D = 24,
            /// <c> add </c>
            SYMBOL_ADD = 25,
            /// <c> 'append light' </c>
            SYMBOL_APPENDLIGHT = 26,
            /// <c> bezier </c>
            SYMBOL_BEZIER = 27,
            /// <c> black </c>
            SYMBOL_BLACK = 28,
            /// <c> blue </c>
            SYMBOL_BLUE = 29,
            /// <c> bmp </c>
            SYMBOL_BMP = 30,
            /// <c> call </c>
            SYMBOL_CALL = 31,
            /// <c> circle </c>
            SYMBOL_CIRCLE = 32,
            /// <c> clear </c>
            SYMBOL_CLEAR = 33,
            /// <c> Collection </c>
            SYMBOL_COLLECTION = 34,
            /// <c> color </c>
            SYMBOL_COLOR = 35,
            /// <c> csg </c>
            SYMBOL_CSG = 36,
            /// <c> cube </c>
            SYMBOL_CUBE = 37,
            /// <c> display </c>
            SYMBOL_DISPLAY = 38,
            /// <c> do </c>
            SYMBOL_DO = 39,
            /// <c> draw </c>
            SYMBOL_DRAW = 40,
            /// <c> ellipse </c>
            SYMBOL_ELLIPSE = 41,
            /// <c> else </c>
            SYMBOL_ELSE = 42,
            /// <c> end </c>
            SYMBOL_END = 43,
            /// <c> endif </c>
            SYMBOL_ENDIF = 44,
            /// <c> endwhile </c>
            SYMBOL_ENDWHILE = 45,
            /// <c> exit </c>
            SYMBOL_EXIT = 46,
            /// <c> false </c>
            SYMBOL_FALSE = 47,
            /// <c> first </c>
            SYMBOL_FIRST = 48,
            /// <c> function </c>
            SYMBOL_FUNCTION = 49,
            /// <c> green </c>
            SYMBOL_GREEN = 50,
            /// <c> Id </c>
            SYMBOL_ID = 51,
            /// <c> if </c>
            SYMBOL_IF = 52,
            /// <c> jpeg </c>
            SYMBOL_JPEG = 53,
            /// <c> jpg </c>
            SYMBOL_JPG = 54,
            /// <c> last </c>
            SYMBOL_LAST = 55,
            /// <c> line </c>
            SYMBOL_LINE = 56,
            /// <c> load </c>
            SYMBOL_LOAD = 57,
            /// <c> NumberLiteral </c>
            SYMBOL_NUMBERLITERAL = 58,
            /// <c> orange </c>
            SYMBOL_ORANGE = 59,
            /// <c> pen </c>
            SYMBOL_PEN = 60,
            /// <c> plane </c>
            SYMBOL_PLANE = 61,
            /// <c> png </c>
            SYMBOL_PNG = 62,
            /// <c> point </c>
            SYMBOL_POINT = 63,
            /// <c> polygon </c>
            SYMBOL_POLYGON = 64,
            /// <c> procedure </c>
            SYMBOL_PROCEDURE = 65,
            /// <c> purple </c>
            SYMBOL_PURPLE = 66,
            /// <c> rectangle </c>
            SYMBOL_RECTANGLE = 67,
            /// <c> red </c>
            SYMBOL_RED = 68,
            /// <c> reflection </c>
            SYMBOL_REFLECTION = 69,
            /// <c> remove </c>
            SYMBOL_REMOVE = 70,
            /// <c> save </c>
            SYMBOL_SAVE = 71,
            /// <c> scaling </c>
            SYMBOL_SCALING = 72,
            /// <c> 'set camera' </c>
            SYMBOL_SETCAMERA = 73,
            /// <c> size </c>
            SYMBOL_SIZE = 74,
            /// <c> sphere </c>
            SYMBOL_SPHERE = 75,
            /// <c> square </c>
            SYMBOL_SQUARE = 76,
            /// <c> StringLiteral </c>
            SYMBOL_STRINGLITERAL = 77,
            /// <c> then </c>
            SYMBOL_THEN = 78,
            /// <c> tiff </c>
            SYMBOL_TIFF = 79,
            /// <c> translation </c>
            SYMBOL_TRANSLATION = 80,
            /// <c> true </c>
            SYMBOL_TRUE = 81,
            /// <c> while </c>
            SYMBOL_WHILE = 82,
            /// <c> white </c>
            SYMBOL_WHITE = 83,
            /// <c> wmf </c>
            SYMBOL_WMF = 84,
            /// <c> yellow </c>
            SYMBOL_YELLOW = 85,
            /// <c> &lt;Bool_Expression&gt; </c>
            SYMBOL_BOOL_EXPRESSION = 86,
            /// <c> &lt;Colors&gt; </c>
            SYMBOL_COLORS = 87,
            /// <c> &lt;Command&gt; </c>
            SYMBOL_COMMAND = 88,
            /// <c> &lt;Comparison&gt; </c>
            SYMBOL_COMPARISON = 89,
            /// <c> &lt;Format&gt; </c>
            SYMBOL_FORMAT = 90,
            /// <c> &lt;Math_Expression&gt; </c>
            SYMBOL_MATH_EXPRESSION = 91,
            /// <c> &lt;Obj_Name&gt; </c>
            SYMBOL_OBJ_NAME = 92,
            /// <c> &lt;Object&gt; </c>
            SYMBOL_OBJECT = 93,
            /// <c> &lt;Operators&gt; </c>
            SYMBOL_OPERATORS = 94,
            /// <c> &lt;params&gt; </c>
            SYMBOL_PARAMS = 95,
            /// <c> &lt;Start&gt; </c>
            SYMBOL_START = 96,
            /// <c> &lt;Statement&gt; </c>
            SYMBOL_STATEMENT = 97,
            /// <c> &lt;Statements&gt; </c>
            SYMBOL_STATEMENTS = 98,
            /// <c> &lt;Transformation&gt; </c>
            SYMBOL_TRANSFORMATION = 99
        };

        enum Rules : int
        {
            /// <c> &lt;Start&gt; ::= '2D' &lt;Statements&gt; </c>
            RULE_START_2D = 0,
            /// <c> &lt;Start&gt; ::= '3D' &lt;Statements&gt; </c>
            RULE_START_3D = 1,
            /// <c> &lt;Statements&gt; ::= &lt;Statement&gt; &lt;Statements&gt; </c>
            RULE_STATEMENTS = 2,
            /// <c> &lt;Statements&gt; ::= &lt;Statement&gt; </c>
            RULE_STATEMENTS2 = 3,
            /// <c> &lt;Statement&gt; ::= &lt;Command&gt; '(' &lt;params&gt; ')' </c>
            RULE_STATEMENT_LPARAN_RPARAN = 4,
            /// <c> &lt;Statement&gt; ::= save &lt;Format&gt; StringLiteral </c>
            RULE_STATEMENT_SAVE_STRINGLITERAL = 5,
            /// <c> &lt;Statement&gt; ::= load StringLiteral </c>
            RULE_STATEMENT_LOAD_STRINGLITERAL = 6,
            /// <c> &lt;Statement&gt; ::= Id '=' &lt;Object&gt; </c>
            RULE_STATEMENT_ID_EQ = 7,
            /// <c> &lt;Statement&gt; ::= if &lt;Bool_Expression&gt; then &lt;Statements&gt; endif </c>
            RULE_STATEMENT_IF_THEN_ENDIF = 8,
            /// <c> &lt;Statement&gt; ::= if &lt;Bool_Expression&gt; then &lt;Statements&gt; else &lt;Statements&gt; endif </c>
            RULE_STATEMENT_IF_THEN_ELSE_ENDIF = 9,
            /// <c> &lt;Statement&gt; ::= while &lt;Bool_Expression&gt; do &lt;Statements&gt; endwhile </c>
            RULE_STATEMENT_WHILE_DO_ENDWHILE = 10,
            /// <c> &lt;Statement&gt; ::= color &lt;Colors&gt; </c>
            RULE_STATEMENT_COLOR = 11,
            /// <c> &lt;Statement&gt; ::= pen NumberLiteral </c>
            RULE_STATEMENT_PEN_NUMBERLITERAL = 12,
            /// <c> &lt;Statement&gt; ::= pen Id </c>
            RULE_STATEMENT_PEN_ID = 13,
            /// <c> &lt;Statement&gt; ::= procedure Id '(' &lt;params&gt; ')' '{' &lt;Statements&gt; '}' </c>
            RULE_STATEMENT_PROCEDURE_ID_LPARAN_RPARAN_LBRACE_RBRACE = 14,
            /// <c> &lt;Statement&gt; ::= call Id '(' &lt;params&gt; ')' </c>
            RULE_STATEMENT_CALL_ID_LPARAN_RPARAN = 15,
            /// <c> &lt;Statement&gt; ::= Collection Id </c>
            RULE_STATEMENT_COLLECTION_ID = 16,
            /// <c> &lt;Statement&gt; ::= Id '.' add '(' &lt;Object&gt; ')' </c>
            RULE_STATEMENT_ID_DOT_ADD_LPARAN_RPARAN = 17,
            /// <c> &lt;Statement&gt; ::= Id '.' remove '(' &lt;Object&gt; ')' </c>
            RULE_STATEMENT_ID_DOT_REMOVE_LPARAN_RPARAN = 18,
            /// <c> &lt;Statement&gt; ::= clear Id </c>
            RULE_STATEMENT_CLEAR_ID = 19,
            /// <c> &lt;Statement&gt; ::= function Id '(' &lt;params&gt; ')' &lt;Statements&gt; exit &lt;Object&gt; end </c>
            RULE_STATEMENT_FUNCTION_ID_LPARAN_RPARAN_EXIT_END = 20,
            /// <c> &lt;Statement&gt; ::= 'set camera' '(' &lt;params&gt; ')' </c>
            RULE_STATEMENT_SETCAMERA_LPARAN_RPARAN = 21,
            /// <c> &lt;Statement&gt; ::= 'append light' '(' &lt;params&gt; ')' </c>
            RULE_STATEMENT_APPENDLIGHT_LPARAN_RPARAN = 22,
            /// <c> &lt;Bool_Expression&gt; ::= true </c>
            RULE_BOOL_EXPRESSION_TRUE = 23,
            /// <c> &lt;Bool_Expression&gt; ::= false </c>
            RULE_BOOL_EXPRESSION_FALSE = 24,
            /// <c> &lt;Bool_Expression&gt; ::= &lt;Object&gt; &lt;Comparison&gt; &lt;Object&gt; </c>
            RULE_BOOL_EXPRESSION = 25,
            /// <c> &lt;Bool_Expression&gt; ::= '(' &lt;Bool_Expression&gt; ')' </c>
            RULE_BOOL_EXPRESSION_LPARAN_RPARAN = 26,
            /// <c> &lt;Comparison&gt; ::= '&lt;' </c>
            RULE_COMPARISON_LT = 27,
            /// <c> &lt;Comparison&gt; ::= '&lt;=' </c>
            RULE_COMPARISON_LTEQ = 28,
            /// <c> &lt;Comparison&gt; ::= '&gt;' </c>
            RULE_COMPARISON_GT = 29,
            /// <c> &lt;Comparison&gt; ::= '&gt;=' </c>
            RULE_COMPARISON_GTEQ = 30,
            /// <c> &lt;Comparison&gt; ::= '==' </c>
            RULE_COMPARISON_EQEQ = 31,
            /// <c> &lt;Comparison&gt; ::= '!=' </c>
            RULE_COMPARISON_EXCLAMEQ = 32,
            /// <c> &lt;Object&gt; ::= &lt;Math_Expression&gt; </c>
            RULE_OBJECT = 33,
            /// <c> &lt;Object&gt; ::= StringLiteral </c>
            RULE_OBJECT_STRINGLITERAL = 34,
            /// <c> &lt;Object&gt; ::= &lt;Obj_Name&gt; '(' &lt;params&gt; ')' </c>
            RULE_OBJECT_LPARAN_RPARAN = 35,
            /// <c> &lt;Object&gt; ::= &lt;Transformation&gt; &lt;Object&gt; '(' &lt;params&gt; ')' </c>
            RULE_OBJECT_LPARAN_RPARAN2 = 36,
            /// <c> &lt;Object&gt; ::= Id '[' &lt;Math_Expression&gt; ']' </c>
            RULE_OBJECT_ID_LBRACKET_RBRACKET = 37,
            /// <c> &lt;Object&gt; ::= Id '.' last </c>
            RULE_OBJECT_ID_DOT_LAST = 38,
            /// <c> &lt;Object&gt; ::= Id '.' first </c>
            RULE_OBJECT_ID_DOT_FIRST = 39,
            /// <c> &lt;Object&gt; ::= Id '.' size </c>
            RULE_OBJECT_ID_DOT_SIZE = 40,
            /// <c> &lt;Object&gt; ::= Id '(' &lt;params&gt; ')' </c>
            RULE_OBJECT_ID_LPARAN_RPARAN = 41,
            /// <c> &lt;Math_Expression&gt; ::= Id </c>
            RULE_MATH_EXPRESSION_ID = 42,
            /// <c> &lt;Math_Expression&gt; ::= NumberLiteral </c>
            RULE_MATH_EXPRESSION_NUMBERLITERAL = 43,
            /// <c> &lt;Math_Expression&gt; ::= &lt;Math_Expression&gt; &lt;Operators&gt; &lt;Math_Expression&gt; </c>
            RULE_MATH_EXPRESSION = 44,
            /// <c> &lt;Math_Expression&gt; ::= '(' &lt;Math_Expression&gt; ')' </c>
            RULE_MATH_EXPRESSION_LPARAN_RPARAN = 45,
            /// <c> &lt;Math_Expression&gt; ::= '-' &lt;Math_Expression&gt; </c>
            RULE_MATH_EXPRESSION_MINUS = 46,
            /// <c> &lt;params&gt; ::=  </c>
            RULE_PARAMS = 47,
            /// <c> &lt;params&gt; ::= &lt;Object&gt; ',' &lt;params&gt; </c>
            RULE_PARAMS_COMMA = 48,
            /// <c> &lt;params&gt; ::= &lt;Object&gt; </c>
            RULE_PARAMS2 = 49,
            /// <c> &lt;Operators&gt; ::= '+' </c>
            RULE_OPERATORS_PLUS = 50,
            /// <c> &lt;Operators&gt; ::= '-' </c>
            RULE_OPERATORS_MINUS = 51,
            /// <c> &lt;Operators&gt; ::= '/' </c>
            RULE_OPERATORS_DIV = 52,
            /// <c> &lt;Operators&gt; ::= '*' </c>
            RULE_OPERATORS_TIMES = 53,
            /// <c> &lt;Operators&gt; ::= '%' </c>
            RULE_OPERATORS_PERCENT = 54,
            /// <c> &lt;Command&gt; ::= draw </c>
            RULE_COMMAND_DRAW = 55,
            /// <c> &lt;Command&gt; ::= display </c>
            RULE_COMMAND_DISPLAY = 56,
            /// <c> &lt;Format&gt; ::= jpg </c>
            RULE_FORMAT_JPG = 57,
            /// <c> &lt;Format&gt; ::= jpeg </c>
            RULE_FORMAT_JPEG = 58,
            /// <c> &lt;Format&gt; ::= bmp </c>
            RULE_FORMAT_BMP = 59,
            /// <c> &lt;Format&gt; ::= png </c>
            RULE_FORMAT_PNG = 60,
            /// <c> &lt;Format&gt; ::= tiff </c>
            RULE_FORMAT_TIFF = 61,
            /// <c> &lt;Format&gt; ::= wmf </c>
            RULE_FORMAT_WMF = 62,
            /// <c> &lt;Obj_Name&gt; ::= point </c>
            RULE_OBJ_NAME_POINT = 63,
            /// <c> &lt;Obj_Name&gt; ::= line </c>
            RULE_OBJ_NAME_LINE = 64,
            /// <c> &lt;Obj_Name&gt; ::= polygon </c>
            RULE_OBJ_NAME_POLYGON = 65,
            /// <c> &lt;Obj_Name&gt; ::= rectangle </c>
            RULE_OBJ_NAME_RECTANGLE = 66,
            /// <c> &lt;Obj_Name&gt; ::= square </c>
            RULE_OBJ_NAME_SQUARE = 67,
            /// <c> &lt;Obj_Name&gt; ::= bezier </c>
            RULE_OBJ_NAME_BEZIER = 68,
            /// <c> &lt;Obj_Name&gt; ::= ellipse </c>
            RULE_OBJ_NAME_ELLIPSE = 69,
            /// <c> &lt;Obj_Name&gt; ::= circle </c>
            RULE_OBJ_NAME_CIRCLE = 70,
            /// <c> &lt;Obj_Name&gt; ::= sphere </c>
            RULE_OBJ_NAME_SPHERE = 71,
            /// <c> &lt;Obj_Name&gt; ::= plane </c>
            RULE_OBJ_NAME_PLANE = 72,
            /// <c> &lt;Obj_Name&gt; ::= csg </c>
            RULE_OBJ_NAME_CSG = 73,
            /// <c> &lt;Obj_Name&gt; ::= cube </c>
            RULE_OBJ_NAME_CUBE = 74,
            /// <c> &lt;Transformation&gt; ::= translation </c>
            RULE_TRANSFORMATION_TRANSLATION = 75,
            /// <c> &lt;Transformation&gt; ::= reflection </c>
            RULE_TRANSFORMATION_REFLECTION = 76,
            /// <c> &lt;Transformation&gt; ::= scaling </c>
            RULE_TRANSFORMATION_SCALING = 77,
            /// <c> &lt;Colors&gt; ::= red </c>
            RULE_COLORS_RED = 78,
            /// <c> &lt;Colors&gt; ::= orange </c>
            RULE_COLORS_ORANGE = 79,
            /// <c> &lt;Colors&gt; ::= yellow </c>
            RULE_COLORS_YELLOW = 80,
            /// <c> &lt;Colors&gt; ::= green </c>
            RULE_COLORS_GREEN = 81,
            /// <c> &lt;Colors&gt; ::= blue </c>
            RULE_COLORS_BLUE = 82,
            /// <c> &lt;Colors&gt; ::= purple </c>
            RULE_COLORS_PURPLE = 83,
            /// <c> &lt;Colors&gt; ::= black </c>
            RULE_COLORS_BLACK = 84,
            /// <c> &lt;Colors&gt; ::= white </c>
            RULE_COLORS_WHITE = 85
        };

        #endregion
    }

    
}